Summary of image types

Following types are defined in utype.h and can be used anywhere if their definations are included:

typedef enum {
    T_RGBA,                     /* packed RGBA values            */
    T_GRAY,                     /* packed RGBA grayscale         */
    T_CMAP,                     /* mapped images having ci_t type */
    T_GMAP,                     /* gray scale mapped images       */
    T_BW,                       /* Black & White images          */
    T_RGB,                      /* Internal type  (unused)       */
    T_FLEX                      /* flexible(unknown) types       */
} IMG_TYPE;

All types have the obvious meaning except T_FLEX, which indicates an unknown type, or, in other words, any type is ok. A global function is provided to convert between all types:

extern int image_convert_type(IPTR im, IMG_TYPE newtype);

This function will convert the image, pointed to by im, to the requestd type newtype. If conversion is sucsseful, a positive value or zero will be retuned and otherwise a negative value will be returned. All errors or reasons for failure are handled by the conversion routine and there is no need to call error handling routines by the caller, although the caller must take appropriate action in case of failure.

Exact type of an image can be checked using the following macros:

 IS_RGBA(im)         /* checks if image im is in color,packed pixel */
 IS_MGRAY(im)        /* checks if image im is gray in CI      */
 IS_BW(im)           /* checks if image im is black & white   */
 IS_CI(im)           /* checks if image im is in CI           */
 IS_RGBGRAY(im)      /* checks if image im is gray in packed  */
 IS_CPACK(im)        /* checks if image im is in packed pixel */
 IS_GRAY(im)         /* checks if image im is in packed pixel */